﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CloudSoft.Extensions;

namespace ERPStore.Exporter.Models.LeadSources
{
	public class HelloproSource : ERPStore.Models.LeadSourceBase
	{
		public override string Id
		{
			get { return "C4E5D5D2-7141-4B0A-BFC0-E8C25835E030"; }
		}

		public override string Name
		{
			get { return "Hellopro"; }
		}

		public override string Description
		{
			get { return "Moteur de comparaison Hellopro"; }
		}

		public override string TrackSourceId
		{
			get { return "hellopro"; }
		}

		public override string Medium
		{
			get { return "cpc"; }
		}

		public override ERPStore.Models.LeadSourceType LeadSourceType
		{
			get { return ERPStore.Models.LeadSourceType.PriceComparator; }
		}

		public override bool Match(Uri sourceUri, Uri landingUri, out string keywords, out string subHost, out decimal amount)
		{
			keywords = null;
			subHost = null;
			amount = 0;
			var landingPrms = landingUri.GetParameters();
			if (landingPrms.AllKeys.Contains("gclid")) // Lien sponso 
			{
				return false;
			}
			else if (landingPrms.AllKeys.Contains("estid"))
			{
				var estid = landingPrms["estid"];
				if (estid.Equals("hellopro", StringComparison.InvariantCultureIgnoreCase))
				{
					amount = 0.2m;
					subHost = "No referer";
					return true;
				}
			}
			else if (sourceUri.Host.ToLower().IndexOf("hellopro.") != -1)
			{
				return true;
			}

			return false;
		}

	}
}
